<template>
  <div class="student-sign">
    <el-dialog :visible.sync="dialogVisible" width="28%" class="el-wrap" @open="onDialogOpen">
      <el-table class="elTable" :data="signList" stripe>
        <el-table-column prop="sigNo" label="签到编号">
          <template slot-scope="scope">
            <div class="sign-row-data">
              <i class="iconfont icon-number"></i>
              {{scope.row.sigNo}}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="gmtCreate" label="签到日期" width="230px">
          <template slot-scope="scope">
            <div class="sign-row-data">
              <i class="iconfont icon-riqi"></i>
              {{scope.row.gmtCreate}}
            </div>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'studentSignDialog',
  props: {
    visible: Boolean,
    stuNo: String
  },
  data () {
    return {
      dialogVisible: false,
      signList: []
    }
  },
  watch: {
    visible () {
      this.dialogVisible = this.visible
    },
    dialogVisible () {
      this.$emit('update:visible', this.dialogVisible)
    }
  },
  methods: {
    getStudentSign () {
      this.signList = []
      this.$axios.get(`/api/student/${this.stuNo}/sign`)
        .then(response => {
          let result = response.data
          console.log(result)
          if (result.success) {
            this.signList = result.data
          } else {
            this.$message.error(result.msg)
          }
        })
    },
    onDialogOpen () {
      this.getStudentSign()
    }
  }
}
</script>

<style lang="stylus" scoped>
.elTable >>> .is-leaf {
  text-align: center;
}

.elTable >>> .sign-row-data {
  text-align: left;
}

.elTable >>> .iconfont {
  margin-left: 20px;
}

.dialog-footer-sign {
  width: 100%;
}
</style>
